<script setup lang="ts">
import { ref } from "vue";

let money = ref(999)
const handler = ($parent:number) => {
  money.value+=1000;
  $parent.money-=1000;
  console.log($parent);
}
</script>

<template>
<div class="daughter">
  <h2>我是Daughter:money{{money}}</h2>
<!--  $parent注入父组件实例-->
  <button @click="handler($parent)">获取1000元</button>
</div>
</template>

<style scoped>
.daughter {
  width:300px;
  height: 300px;
  background: salmon;
}
</style>